function y = sinc_interp(x,u)
% sinc_interp  - 1-D (full) sinc interpolation
%
% FORMAT:       y = sinc_interp(x, u)
%
% Input fields:
%
%       x           signal
%       u           interpolation points (0 .. n-1)
%
% Output fields:
%
%       y           interpolated signal

% Version:  v0.7c
% Build:    7120607
% Date:     Dec-06 2007, 7:59 AM CET
% Author:   unknown
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

m = 0:(numel(x) - 1);
y = x(1);
y(1:numel(u)) = 0;
y = reshape(y, size(u));
for i=1:length(u)
  y(i) = sum(x .* sinc_val(m- u(i)));
end

function y = sinc_val(x)
i=find(x==0);                                                              
x(i)= 1;
y = sin(pi*x)./(pi*x);                                                     
y(i) = 1;   
% end of function y = sinc_val(x)
